<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>编辑企业 - 测盟汇系统</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
    <style>
        :root {
            --primary-color: #2c5545;
            --primary-light: #3a7d62;
            --primary-hover: #1e4636;
            --error-color: #d64541;
            --text-color: #333;
            --text-light: #555;
            --border-color: #d1d9d6;
            --bg-light: #f5f7f6;
            --bg-page: #e8ecea;
            --white: #fff;
            --shadow: 0 4px 24px rgba(44, 85, 69, 0.1);
            --radius: 8px;
            --transition: all 0.3s ease;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            background: var(--bg-page);
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            color: var(--text-color);
            line-height: 1.6;
            padding: 20px;
        }

        .container {
            max-width: 800px;
            margin: 0 auto;
            background: var(--white);
            padding: 2rem;
            border-radius: var(--radius);
            box-shadow: var(--shadow);
        }

        h1 {
            color: var(--primary-color);
            margin-bottom: 1.5rem;
            padding-bottom: 0.5rem;
            border-bottom: 2px solid var(--primary-light);
            display: flex;
            align-items: center;
        }

        h1 i {
            margin-right: 0.8rem;
        }

        .form-group {
            margin-bottom: 1.5rem;
        }

        label {
            display: block;
            margin-bottom: 0.5rem;
            color: var(--primary-color);
            font-weight: 500;
        }

        label.required::after {
            content: '*';
            color: var(--error-color);
            margin-left: 4px;
        }

        input[type="text"],
        input[type="password"],
        input[type="email"],
        input[type="tel"],
        select {
            width: 100%;
            padding: 0.8rem;
            border: 1px solid var(--border-color);
            border-radius: var(--radius);
            font-size: 1rem;
            background: var(--bg-light);
            transition: var(--transition);
        }

        input:focus,
        select:focus {
            border-color: var(--primary-color);
            outline: none;
            box-shadow: 0 0 0 2px rgba(44, 85, 69, 0.2);
            background: var(--white);
        }

        .error {
            color: var(--error-color);
            font-size: 0.9rem;
            margin-top: 0.3rem;
            display: flex;
            align-items: center;
        }

        .error i {
            margin-right: 0.3rem;
        }

        .button-group {
            display: flex;
            justify-content: space-between;
            margin-top: 2rem;
        }

        .btn {
            padding: 0.8rem 1.5rem;
            border-radius: var(--radius);
            border: none;
            cursor: pointer;
            font-weight: 500;
            transition: var(--transition);
            display: inline-flex;
            align-items: center;
        }

        .btn i {
            margin-right: 0.5rem;
        }

        .btn-primary {
            background: var(--primary-color);
            color: var(--white);
        }

        .btn-primary:hover {
            background: var(--primary-hover);
            transform: translateY(-2px);
        }

        .btn-secondary {
            background: var(--bg-light);
            color: var(--text-color);
            border: 1px solid var(--border-color);
        }

        .btn-secondary:hover {
            background: #e1e8e4;
            transform: translateY(-2px);
        }

        .status-badge {
            display: inline-block;
            padding: 0.3rem 0.6rem;
            border-radius: 20px;
            font-size: 0.8rem;
            font-weight: 500;
        }

        .status-active {
            background: #d4edda;
            color: #155724;
        }

        .status-inactive {
            background: #f8d7da;
            color: #721c24;
        }

        .form-row {
            display: flex;
            gap: 1rem;
        }

        .form-row .form-group {
            flex: 1;
        }

        @media (max-width: 768px) {
            .form-row {
                flex-direction: column;
                gap: 0;
            }

            .container {
                padding: 1.5rem;
            }
        }
    </style>
</head>
<body>
<div class="container">
    <h1>
        <i class="fas fa-building"></i>
        编辑企业信息
    </h1>

    <form th:action="@{/enterprise/update}" th:object="${enterprise}" method="post">
        <input type="hidden" th:field="*{id}" />
        <input type="hidden" th:field="*{createTime}" />

        <div class="form-group">
            <label for="enterpriseName" class="required">企业名称</label>
            <input type="text" id="enterpriseName" th:field="*{enterpriseName}" required>
        </div>

        <div class="form-row">
            <div class="form-group">
                <label for="account" class="required">企业账号</label>
                <input type="text" id="account" th:field="*{account}" required>
            </div>

            <div class="form-group">
                <label for="status">状态</label>
                <select id="status" th:field="*{status}">
                    <option value="1">已激活</option>
                    <option value="0">已禁用</option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label for="password">重置密码</label>
            <input type="password" id="password" name="password" placeholder="留空则不修改密码">
            <small style="color: var(--text-light);">如需修改密码，请在此输入新密码</small>
        </div>

        <div class="form-group">
            <label for="contactInfo" class="required">联系方式</label>
            <input type="tel" id="contactInfo" th:field="*{contactInfo}" required>
        </div>

        <div th:if="${error}" class="error">
            <i class="fas fa-exclamation-circle"></i>
            <span th:text="${error}"></span>
        </div>

        <div class="button-group">
            <a th:href="@{/enterprise/list}" class="btn btn-secondary">
                <i class="fas fa-arrow-left"></i> 返回列表
            </a>
            <button type="submit" class="btn btn-primary">
                <i class="fas fa-save"></i> 保存修改
            </button>
        </div>
    </form>
</div>

<script>
    // 自动聚焦到第一个可编辑字段
    document.addEventListener('DOMContentLoaded', function() {
        const firstInput = document.querySelector('input:not([readonly]):not([type="hidden"])');
        if (firstInput) {
            firstInput.focus();
        }
    });
</script>
</body>
</html>